package com.yzt.message.custom;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;

import java.util.ArrayList;
import java.util.List;

import io.rong.imkit.config.RongConfigCenter;
import io.rong.imkit.conversation.extension.component.emoticon.AndroidEmoji;
import io.rong.imlib.model.MessageContent;
import io.rong.message.InformationNotificationMessage;

/**
 * 聊天页面得自定义布局管理者
 */
public class CustomConversationProviderManager {

    private static final List<Class> NoSummaryClass = new ArrayList<>();

    static {
        //不暂时内容在列表中得，放到这里过滤，会自动使用上一条正常展示得
        NoSummaryClass.add(RXCustomTipMessageContent.class);
        NoSummaryClass.add(InformationNotificationMessage.class);
        NoSummaryClass.add(RXLongTipMessageContent.class);
        NoSummaryClass.add(RXShowTipMessageContent.class);
       // NoSummaryClass.add(RXProfileCardContent.class);
    }

    public static boolean isNoSummaryMessage(MessageContent messageContent) {
        if (messageContent == null) {
            return false;
        }
        for (Class cls : NoSummaryClass) {
            if (messageContent.getClass() == cls) {
                return true;
            }
        }
        return false;
    }

    public static Spannable getContentSummary(Context context, MessageContent data) {
        if (data.isDestruct()) {
            return new SpannableString(context.getString(io.rong.imkit.R.string.rc_message_content_burn));
        }

        SpannableStringBuilder builder = new SpannableStringBuilder();
        Spannable summary = RongConfigCenter.conversationConfig().getMessageSummary(context, data);
        builder.append(summary);
        AndroidEmoji.ensure(builder);
        return builder;
    }
}
